﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace JasLib.Interop.Win32
{
    /// <summary>
    /// These methods return <seealso cref="Win32ErrorCode"/> instead of NET_API_STATUS because 
    /// the two are part of the same numbering space and <seealso cref="Win32ErrorCode"/> incorporates the latter.
    /// </summary>
    public static partial class NETAPI32
    {
        [DllImport(Constants.ModuleNames.NETAPI32, EntryPoint = "NetApiBufferAllocate", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
        public static extern Win32ErrorCode NetApiBufferAllocate(
            [In] uint ByteCount,
            [Out] out UINT_PTR Buffer);

        [DllImport(Constants.ModuleNames.NETAPI32, EntryPoint = "NetApiBufferFree", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
        public static extern Win32ErrorCode NetApiBufferFree([In] UINT_PTR Buffer);

        [DllImport(Constants.ModuleNames.NETAPI32, EntryPoint = "NetApiBufferReallocate", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
        public static extern Win32ErrorCode NetApiBufferReallocate(
            [In] UINT_PTR OldBuffer,
            [In] uint NewByteCount,
            [Out] out UINT_PTR NewBuffer);

        [DllImport(Constants.ModuleNames.NETAPI32, EntryPoint = "NetRemoteTOD", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
        public static extern Win32ErrorCode NetRemoteTOD(
            [In, MarshalAs(UnmanagedType.LPWStr)] string UncServerName,
            [Out] out UINT_PTR BufferPtr);
    }
}